<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/includes/site_defaults.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/database/db.php');


$to = "greenautomarket@gmail.com";
$from = "greenautomarket@gmail.com";

if (isset($_REQUEST['email'])) {
	$from = $_REQUEST['email'];
} 

if (isset($_REQUEST['contact_id'])) {
	$qry = "SELECT username FROM contacts WHERE id = ".$_REQUEST['contact_id'];
	mysql_select_db($db_name, $db);
	$result = mysql_query($qry) or $errors[] = mysql_error();
	$user = mysql_fetch_assoc($result);
	$to = $user["username"];
}


$message = $_REQUEST['message'] ;
mail($to, "Message from GreenAutoMarket.org",
	$message, "From: $from" );
header( "Location: thankyou.php" );
?>
